import OpenAI from "openai";

const openai = new OpenAI({
    baseURL: 'https://api.deepseek.com',
    apiKey: 'sk-f6884c0f138248a19e8a9869da52952c',
    dangerouslyAllowBrowser: true 
})


export const consult = {
    // 查询咨询记录列表接口
    async getAllConsultList(message: string) {
        console.log("【接收到的问题】",message);
        try {
            const completion = await openai.chat.completions.create({
                messages: [{ role: "system", content: message }],
                model: "deepseek-chat",
            });
            let result = completion.choices[0].message.content;
            console.log(completion.choices[0].message.content);
            return {success:true,completion}
        } catch (err) {
            console.log('【err: in function getAllConsultList】', err);
            return { success: false ,result:'请求出错错误'};
            
        }
        
    },
}

